/**
 * React Router DOM v6.17.0
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */
import*as e from"react";import{UNSAFE_mapRouteProperties as t,UNSAFE_DataRouterContext as n,UNSAFE_DataRouterStateContext as r,Router as o,UNSAFE_useRoutesImpl as a,UNSAFE_NavigationContext as i,useHref as s,useResolvedPath as u,useLocation as l,useNavigate as c,createPath as f,UNSAFE_useRouteId as m,UNSAFE_RouteContext as d,useMatches as p,useNavigation as h,unstable_useBlocker as w}from"react-router";export{AbortedDeferredError,Await,MemoryRouter,Navigate,NavigationType,Outlet,Route,Router,Routes,UNSAFE_DataRouterContext,UNSAFE_DataRouterStateContext,UNSAFE_LocationContext,UNSAFE_NavigationContext,UNSAFE_RouteContext,UNSAFE_useRouteId,createMemoryRouter,createPath,createRoutesFromChildren,createRoutesFromElements,defer,generatePath,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,redirectDocument,renderMatches,resolvePath,unstable_useBlocker,useActionData,useAsyncError,useAsyncValue,useHref,useInRouterContext,useLoaderData,useLocation,useMatch,useMatches,useNavigate,useNavigation,useNavigationType,useOutlet,useOutletContext,useParams,useResolvedPath,useRevalidator,useRouteError,useRouteLoaderData,useRoutes}from"react-router";import{stripBasename as v,createRouter as g,createBrowserHistory as b,createHashHistory as y,UNSAFE_ErrorResponseImpl as R,UNSAFE_invariant as S,joinPaths as E,matchPath as T}from"@remix-run/router";const L="application/x-www-form-urlencoded";function C(e){return null!=e&&"string"==typeof e.tagName}function x(e=""){return new URLSearchParams("string"==typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce(((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map((e=>[n,e])):[[n,r]])}),[]))}let _=null;const A=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function F(e){return null==e||A.has(e)?e:null}function U(e,t){let n,r,o,a,i;if(C(s=e)&&"form"===s.tagName.toLowerCase()){let i=e.getAttribute("action");r=i?v(i,t):null,n=e.getAttribute("method")||"get",o=F(e.getAttribute("enctype"))||L,a=new FormData(e)}else if(function(e){return C(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return C(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let i=e.form;if(null==i)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let s=e.getAttribute("formaction")||i.getAttribute("action");if(r=s?v(s,t):null,n=e.getAttribute("formmethod")||i.getAttribute("method")||"get",o=F(e.getAttribute("formenctype"))||F(i.getAttribute("enctype"))||L,a=new FormData(i,e),!function(){if(null===_)try{new FormData(document.createElement("form"),0),_=!1}catch(e){_=!0}return _}()){let{name:t,type:n,value:r}=e;if("image"===n){let e=t?`${t}.`:"";a.append(`${e}x`,"0"),a.append(`${e}y`,"0")}else t&&a.append(t,r)}}else{if(C(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n="get",r=null,o=L,i=e}var s;return a&&"text/plain"===o&&(i=a,a=void 0),{action:r,method:n.toLowerCase(),encType:o,formData:a,body:i}}function k(e,n){return g({basename:n?.basename,future:{...n?.future,v7_prependBasename:!0},history:b({window:n?.window}),hydrationData:n?.hydrationData||N(),routes:e,mapRouteProperties:t,window:n?.window}).initialize()}function D(e,n){return g({basename:n?.basename,future:{...n?.future,v7_prependBasename:!0},history:y({window:n?.window}),hydrationData:n?.hydrationData||N(),routes:e,mapRouteProperties:t,window:n?.window}).initialize()}function N(){let e=window?.__staticRouterHydrationData;return e&&e.errors&&(e={...e,errors:P(e.errors)}),e}function P(e){if(!e)return null;let t=Object.entries(e),n={};for(let[o,a]of t)if(a&&"RouteErrorResponse"===a.__type)n[o]=new R(a.status,a.statusText,a.data,!0===a.internal);else if(a&&"Error"===a.__type){if(a.__subType){let e=window[a.__subType];if("function"==typeof e)try{let t=new e(a.message);t.stack="",n[o]=t}catch(r){}}if(null==n[o]){let e=new Error(a.message);e.stack="",n[o]=e}}else n[o]=a;return n}const O=e.createContext({isTransitioning:!1}),j=e.startTransition;class M{status="pending";constructor(){this.promise=new Promise(((e,t)=>{this.resolve=t=>{"pending"===this.status&&(this.status="resolved",e(t))},this.reject=e=>{"pending"===this.status&&(this.status="rejected",t(e))}}))}}function K({fallbackElement:t,router:a,future:i}){let[s,u]=e.useState(a.state),[l,c]=e.useState(),[f,m]=e.useState({isTransitioning:!1}),[d,p]=e.useState(),[h,w]=e.useState(),[v,g]=e.useState(),{v7_startTransition:b}=i||{},y=e.useCallback((e=>{b?function(e){j?j(e):e()}(e):e()}),[b]),R=e.useCallback(((e,{unstable_viewTransitionOpts:t})=>{t&&null!=a.window&&"function"==typeof a.window.document.startViewTransition?h&&d?(d.resolve(),h.skipTransition(),g({state:e,currentLocation:t.currentLocation,nextLocation:t.nextLocation})):(c(e),m({isTransitioning:!0,currentLocation:t.currentLocation,nextLocation:t.nextLocation})):y((()=>u(e)))}),[y,h,d,a.window]);e.useLayoutEffect((()=>a.subscribe(R)),[a,R]),e.useEffect((()=>{f.isTransitioning&&p(new M)}),[f.isTransitioning]),e.useEffect((()=>{if(d&&l&&a.window){let e=l,t=d.promise,n=a.window.document.startViewTransition((async()=>{y((()=>u(e))),await t}));n.finished.finally((()=>{p(void 0),w(void 0),c(void 0),m({isTransitioning:!1})})),w(n)}}),[y,l,d,a.window]),e.useEffect((()=>{d&&l&&s.location.key===l.location.key&&d.resolve()}),[d,h,s.location,l]),e.useEffect((()=>{!f.isTransitioning&&v&&(c(v.state),m({isTransitioning:!0,currentLocation:v.currentLocation,nextLocation:v.nextLocation}),g(void 0))}),[f.isTransitioning,v]);let S=e.useMemo((()=>({createHref:a.createHref,encodeLocation:a.encodeLocation,go:e=>a.navigate(e),push:(e,t,n)=>a.navigate(e,{state:t,preventScrollReset:n?.preventScrollReset}),replace:(e,t,n)=>a.navigate(e,{replace:!0,state:t,preventScrollReset:n?.preventScrollReset})})),[a]),E=a.basename||"/",T=e.useMemo((()=>({router:a,navigator:S,static:!1,basename:E})),[a,S,E]);return e.createElement(e.Fragment,null,e.createElement(n.Provider,{value:T},e.createElement(r.Provider,{value:s},e.createElement(O.Provider,{value:f},e.createElement(o,{basename:E,location:s.location,navigationType:s.historyAction,navigator:S},s.initialized?e.createElement(V,{routes:a.routes,state:s}):t)))),null)}function V({routes:e,state:t}){return a(e,void 0,t)}function I({basename:t,children:n,future:r,window:a}){let i=e.useRef();null==i.current&&(i.current=b({window:a,v5Compat:!0}));let s=i.current,[u,l]=e.useState({action:s.action,location:s.location}),{v7_startTransition:c}=r||{},f=e.useCallback((e=>{c&&j?j((()=>l(e))):l(e)}),[l,c]);return e.useLayoutEffect((()=>s.listen(f)),[s,f]),e.createElement(o,{basename:t,children:n,location:u.location,navigationType:u.action,navigator:s})}function z({basename:t,children:n,future:r,window:a}){let i=e.useRef();null==i.current&&(i.current=y({window:a,v5Compat:!0}));let s=i.current,[u,l]=e.useState({action:s.action,location:s.location}),{v7_startTransition:c}=r||{},f=e.useCallback((e=>{c&&j?j((()=>l(e))):l(e)}),[l,c]);return e.useLayoutEffect((()=>s.listen(f)),[s,f]),e.createElement(o,{basename:t,children:n,location:u.location,navigationType:u.action,navigator:s})}function B({basename:t,children:n,future:r,history:a}){let[i,s]=e.useState({action:a.action,location:a.location}),{v7_startTransition:u}=r||{},l=e.useCallback((e=>{u&&j?j((()=>s(e))):s(e)}),[s,u]);return e.useLayoutEffect((()=>a.listen(l)),[a,l]),e.createElement(o,{basename:t,children:n,location:i.location,navigationType:i.action,navigator:a})}const H="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,$=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,W=e.forwardRef((function({onClick:t,relative:n,reloadDocument:r,replace:o,state:a,target:u,to:l,preventScrollReset:c,unstable_viewTransition:f,...m},d){let p,{basename:h}=e.useContext(i),w=!1;if("string"==typeof l&&$.test(l)&&(p=l,H))try{let e=new URL(window.location.href),t=l.startsWith("//")?new URL(e.protocol+l):new URL(l),n=v(t.pathname,h);t.origin===e.origin&&null!=n?l=n+t.search+t.hash:w=!0}catch(y){}let g=s(l,{relative:n}),b=te(l,{replace:o,state:a,target:u,preventScrollReset:c,relative:n,unstable_viewTransition:f});return e.createElement("a",Object.assign({},m,{href:p||g,onClick:w||r?t:function(e){t&&t(e),e.defaultPrevented||b(e)},ref:d,target:u}))})),Y=e.forwardRef((function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:a=!1,style:s,to:c,unstable_viewTransition:f,children:m,...d},p){let h=u(c,{relative:d.relative}),w=l(),v=e.useContext(r),{navigator:g}=e.useContext(i),b=null!=v&&pe(h)&&!0===f,y=g.encodeLocation?g.encodeLocation(h).pathname:h.pathname,R=w.pathname,S=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;n||(R=R.toLowerCase(),S=S?S.toLowerCase():null,y=y.toLowerCase());let E,T=R===y||!a&&R.startsWith(y)&&"/"===R.charAt(y.length),L=null!=S&&(S===y||!a&&S.startsWith(y)&&"/"===S.charAt(y.length)),C={isActive:T,isPending:L,isTransitioning:b},x=T?t:void 0;E="function"==typeof o?o(C):[o,T?"active":null,L?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let _="function"==typeof s?s(C):s;return e.createElement(W,Object.assign({},d,{"aria-current":x,className:E,ref:p,style:_,to:c,unstable_viewTransition:f}),"function"==typeof m?m(C):m)})),J=e.forwardRef(((t,n)=>{let r=oe();return e.createElement(q,Object.assign({},t,{submit:r,ref:n}))})),q=e.forwardRef((({reloadDocument:t,replace:n,state:r,method:o="get",action:a,onSubmit:i,submit:s,relative:u,preventScrollReset:l,unstable_viewTransition:c,...f},m)=>{let d="get"===o.toLowerCase()?"get":"post",p=ie(a,{relative:u});return e.createElement("form",Object.assign({ref:m,method:d,action:p,onSubmit:t?i:e=>{if(i&&i(e),e.defaultPrevented)return;e.preventDefault();let t=e.nativeEvent.submitter,a=t?.getAttribute("formmethod")||o;s(t||e.currentTarget,{method:a,replace:n,state:r,relative:u,preventScrollReset:l,unstable_viewTransition:c})}},f))}));function G({getKey:e,storageKey:t}){return fe({getKey:e,storageKey:t}),null}var Q=function(e){return e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState",e}(Q||{}),X=function(e){return e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration",e}(X||{});function Z(t){let r=e.useContext(n);return r||S(!1),r}function ee(t){let n=e.useContext(r);return n||S(!1),n}function te(t,{target:n,replace:r,state:o,preventScrollReset:a,relative:i,unstable_viewTransition:s}={}){let m=c(),d=l(),p=u(t,{relative:i});return e.useCallback((e=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(e,n)){e.preventDefault();let n=void 0!==r?r:f(d)===f(p);m(t,{replace:n,state:o,preventScrollReset:a,relative:i,unstable_viewTransition:s})}}),[d,m,p,r,o,n,t,a,i,s])}function ne(t){let n=e.useRef(x(t)),r=e.useRef(!1),o=l(),a=e.useMemo((()=>function(e,t){let n=x(e);return t&&t.forEach(((e,r)=>{n.has(r)||t.getAll(r).forEach((e=>{n.append(r,e)}))})),n}(o.search,r.current?null:n.current)),[o.search]),i=c(),s=e.useCallback(((e,t)=>{const n=x("function"==typeof e?e(a):e);r.current=!0,i("?"+n,t)}),[i,a]);return[a,s]}function re(){if("undefined"==typeof document)throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.")}function oe(){let{router:t}=Z(Q.UseSubmit),{basename:n}=e.useContext(i),r=m();return e.useCallback(((e,o={})=>{re();let{action:a,method:i,encType:s,formData:u,body:l}=U(e,n);t.navigate(o.action||a,{preventScrollReset:o.preventScrollReset,formData:u,body:l,formMethod:o.method||i,formEncType:o.encType||s,replace:o.replace,state:o.state,fromRouteId:r,unstable_viewTransition:o.unstable_viewTransition})}),[t,n,r])}function ae(t,n){let{router:r}=Z(Q.UseSubmitFetcher),{basename:o}=e.useContext(i);return e.useCallback(((e,a={})=>{re();let{action:i,method:s,encType:u,formData:l,body:c}=U(e,o);null==n&&S(!1),r.fetch(t,n,a.action||i,{preventScrollReset:a.preventScrollReset,formData:l,body:c,formMethod:a.method||s,formEncType:a.encType||u})}),[r,o,t,n])}function ie(t,{relative:n}={}){let{basename:r}=e.useContext(i),o=e.useContext(d);o||S(!1);let[a]=o.matches.slice(-1),s={...u(t||".",{relative:n})},c=l();if(null==t&&(s.search=c.search,a.route.index)){let e=new URLSearchParams(s.search);e.delete("index"),s.search=e.toString()?`?${e.toString()}`:""}return t&&"."!==t||!a.route.index||(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),"/"!==r&&(s.pathname="/"===s.pathname?r:E([r,s.pathname])),f(s)}let se=0;function ue(){let{router:t}=Z(Q.UseFetcher),n=e.useContext(d);n||S(!1);let r=n.matches[n.matches.length-1]?.route.id;null==r&&S(!1);let[o]=e.useState((()=>String(++se))),[a]=e.useState((()=>(r||S(!1),function(t,n){return e.forwardRef(((r,o)=>{let a=ae(t,n);return e.createElement(q,Object.assign({},r,{ref:o,submit:a}))}))}(o,r)))),[i]=e.useState((()=>e=>{t||S(!1),r||S(!1),t.fetch(o,r,e)})),s=ae(o,r),u=t.getFetcher(o),l=e.useMemo((()=>({Form:a,submit:s,load:i,...u})),[u,a,s,i]);return e.useEffect((()=>()=>{t?t.deleteFetcher(o):console.warn("No router available to clean up from useFetcher()")}),[t,o]),l}function le(){return[...ee(X.UseFetchers).fetchers.values()]}let ce={};function fe({getKey:t,storageKey:n}={}){let{router:r}=Z(Q.UseScrollRestoration),{restoreScrollPosition:o,preventScrollReset:a}=ee(X.UseScrollRestoration),{basename:s}=e.useContext(i),u=l(),c=p(),f=h();e.useEffect((()=>(window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration="auto"})),[]),function(t,n){let{capture:r}=n||{};e.useEffect((()=>{let e=null!=r?{capture:r}:void 0;return window.addEventListener("pagehide",t,e),()=>{window.removeEventListener("pagehide",t,e)}}),[t,r])}(e.useCallback((()=>{if("idle"===f.state){let e=(t?t(u,c):null)||u.key;ce[e]=window.scrollY}try{sessionStorage.setItem(n||"react-router-scroll-positions",JSON.stringify(ce))}catch(e){}window.history.scrollRestoration="auto"}),[n,t,f.state,u,c])),"undefined"!=typeof document&&(e.useLayoutEffect((()=>{try{let e=sessionStorage.getItem(n||"react-router-scroll-positions");e&&(ce=JSON.parse(e))}catch(e){}}),[n]),e.useLayoutEffect((()=>{let e=t&&"/"!==s?(e,n)=>t({...e,pathname:v(e.pathname,s)||e.pathname},n):t,n=r?.enableScrollRestoration(ce,(()=>window.scrollY),e);return()=>n&&n()}),[r,s,t]),e.useLayoutEffect((()=>{if(!1!==o)if("number"!=typeof o){if(u.hash){let e=document.getElementById(decodeURIComponent(u.hash.slice(1)));if(e)return void e.scrollIntoView()}!0!==a&&window.scrollTo(0,0)}else window.scrollTo(0,o)}),[u,o,a]))}function me(t,n){let{capture:r}=n||{};e.useEffect((()=>{let e=null!=r?{capture:r}:void 0;return window.addEventListener("beforeunload",t,e),()=>{window.removeEventListener("beforeunload",t,e)}}),[t,r])}function de({when:t,message:n}){let r=w(t);e.useEffect((()=>{if("blocked"===r.state){window.confirm(n)?setTimeout(r.proceed,0):r.reset()}}),[r,n]),e.useEffect((()=>{"blocked"!==r.state||t||r.reset()}),[r,t])}function pe(t,n={}){let r=e.useContext(O);null==r&&S(!1);let{basename:o}=Z(Q.useViewTransitionState),a=u(t,{relative:n.relative});if(!r.isTransitioning)return!1;let i=v(r.currentLocation.pathname,o)||r.currentLocation.pathname,s=v(r.nextLocation.pathname,o)||r.nextLocation.pathname;return null!=T(a.pathname,s)||null!=T(a.pathname,i)}export{I as BrowserRouter,J as Form,z as HashRouter,W as Link,Y as NavLink,K as RouterProvider,G as ScrollRestoration,O as UNSAFE_ViewTransitionContext,fe as UNSAFE_useScrollRestoration,k as createBrowserRouter,D as createHashRouter,x as createSearchParams,B as unstable_HistoryRouter,de as unstable_usePrompt,pe as unstable_useViewTransitionState,me as useBeforeUnload,ue as useFetcher,le as useFetchers,ie as useFormAction,te as useLinkClickHandler,ne as useSearchParams,oe as useSubmit};
//# sourceMappingURL=react-router-dom.production.min.js.map
